In [1]:
import pandas as pd
import csv
import seaborn as sns
sns.set_palette('husl')
import matplotlib.pyplot as plt
%matplotlib inline
%pylab inline
Populating the interactive namespace from numpy and matplotlib
In [2]:
import warnings
warnings.filterwarnings("ignore")
In [3]:
df = pd.read_excel("SPYVIX.xlsx", sheet_name = "SPY")
#df1 = pd.read_excel("SPYVIX.xlsx", sheet_name = "VIX")
In [4]:
df.info()
<class 'pandas.core.frame.DataFrame'>
RangeIndex: 6921 entries, 0 to 6920
Data columns (total 9 columns):
 #   Column                                       Non-Null Count  Dtype         
---  ------                                       --------------  -----         
 0   Date                                         6921 non-null   datetime64[ns]
 1   Open                                         6921 non-null   float64       
 2   Close                                        6921 non-null   float64       
 3   Percent Change (Prev. Close to Next Open)    6920 non-null   float64       
 4   Money Compounded (Prev. Close to Next Open)  6920 non-null   float64       
 5   Percent Change (Same Close to SameOpen)      6921 non-null   float64       
 6   Money Compounded (Same Close to Same Open)   6921 non-null   float64       
 7   Percent Change (Prev Close to Next Close)    6920 non-null   float64       
 8   Money Compounded (Prev Close to Next Close)  6920 non-null   float64       
dtypes: datetime64[ns](1), float64(8)
memory usage: 486.8 KB
In [5]:
df.head()
Out[5]:
Date Open Close Percent Change (Prev. Close to Next Open) Money Compounded (Prev. Close to Next Open) Percent Change (Same Close to SameOpen) Money Compounded (Same Close to Same Open) Percent Change (Prev Close to Next Close) Money Compounded (Prev Close to Next Close)
0 1993-01-29 43.96875 43.93750 0.000711 100.071073 -0.000711 99.928876 0.007062 100.706215
1 1993-02-01 43.96875 44.25000 -0.000707 100.000352 0.006356 100.564017 0.002114 100.919124
2 1993-02-02 44.21875 44.34375 0.001407 100.141098 0.002819 100.847496 0.010460 101.974764
3 1993-02-03 44.40625 44.81250 0.003475 100.489052 0.009066 101.761734 0.004167 102.399658
4 1993-02-04 44.96875 45.00000 -0.000695 100.419219 0.000694 101.832402 -0.000695 102.328498
In [6]:
df.tail()
Out[6]:
Date Open Close Percent Change (Prev. Close to Next Open) Money Compounded (Prev. Close to Next Open) Percent Change (Same Close to SameOpen) Money Compounded (Same Close to Same Open) Percent Change (Prev Close to Next Close) Money Compounded (Prev Close to Next Close)
6916 2020-07-17 321.880005 321.720001 -0.000902 573.025534 -0.000497 47.786855 0.008017 273.274636
6917 2020-07-20 321.429993 324.320007 0.006525 576.764382 0.008911 48.212683 0.002123 273.854804
6918 2020-07-21 326.450012 325.010010 -0.001201 576.071428 -0.004431 47.999070 0.005660 275.404778
6919 2020-07-22 324.619995 326.859985 -0.001195 575.383283 0.006853 48.328011 -0.012076 272.079051
6920 2020-07-23 326.470001 322.959991 NaN NaN -0.010868 47.802770 NaN NaN
In [7]:
df = df[:-1]
In [8]:
df.tail()
Out[8]:
Date Open Close Percent Change (Prev. Close to Next Open) Money Compounded (Prev. Close to Next Open) Percent Change (Same Close to SameOpen) Money Compounded (Same Close to Same Open) Percent Change (Prev Close to Next Close) Money Compounded (Prev Close to Next Close)
6915 2020-07-16 319.790009 320.790009 0.003386 573.543009 0.003117 47.810633 0.002891 271.101274
6916 2020-07-17 321.880005 321.720001 -0.000902 573.025534 -0.000497 47.786855 0.008017 273.274636
6917 2020-07-20 321.429993 324.320007 0.006525 576.764382 0.008911 48.212683 0.002123 273.854804
6918 2020-07-21 326.450012 325.010010 -0.001201 576.071428 -0.004431 47.999070 0.005660 275.404778
6919 2020-07-22 324.619995 326.859985 -0.001195 575.383283 0.006853 48.328011 -0.012076 272.079051
In [9]:
import plotly.express as px
import plotly.graph_objects as go
In [10]:
fig = go.Figure() # go object

Date = df["Date"]
Long = df["Money Compounded (Prev. Close to Next Open)"]
Medium = df["Money Compounded (Same Close to Same Open)"]
Short = df["Money Compounded (Prev Close to Next Close)"]

fig.add_trace(go.Scatter(x=Date, y=Long, name='Money Compounded (Prev. Close to Next Open)',
                         line=dict(color='firebrick', width=3)))
fig.add_trace(go.Scatter(x=Date, y=Medium, name='Money Compounded (Same Close to Same Open)',
                         line=dict(color='royalblue', width=3,)))
fig.add_trace(go.Scatter(x=Date, y=Short, name='Money Compounded (Prev Close to Next Close)',
                         line=dict(color='green', width=3,)))

# Edit the layout
fig.update_layout(title='Growth of $100 Compounded with Different Naive Methods SPY',
                   xaxis_title='Year',
                   yaxis_title='USD Compounded', width=1000, height=800,)
fig.show()
In [11]:
#fig = go.Figure() # go object

#Date = df1["Date"]
#Long = df1["Money Compounded (Prev. Close to Next Open)"]
#Medium = df1["Money Compounded (Same Close to Same Open)"]
#Short = df1["Money Compounded (Prev Close to Next Close)"]

#fig.add_trace(go.Scatter(x=Date, y=Long, name='Money Compounded (Prev. Close to Next Open)',
#                         line=dict(color='firebrick', width=3)))
#fig.add_trace(go.Scatter(x=Date, y=Medium, name='Money Compounded (Same Close to Same Open)',
                         #line=dict(color='royalblue', width=3,)))
#fig.add_trace(go.Scatter(x=Date, y=Short, name='Money Compounded (Prev Close to Next Close)',
#                         line=dict(color='green', width=3,)))

# Edit the layout
#fig.update_layout(title='Growth of $100 Compounded with Different Naive Methods VIX',
#                   xaxis_title='Year',
#                   yaxis_title='USD Compounded', width=1000, height=800,)
#fig.show()
In [ ]: